package com.alibaba.polardbx.qatest.ddl.auto.partition;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runners.Parameterized;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

/**
 * @author chenghui.lch
 */

public class PartitionColumnTypeForRangeColumns3Test extends PartitionColumnTypeTestBase {

    public TestParameter parameter;

    public PartitionColumnTypeForRangeColumns3Test(TestParameter parameter) {
        super(parameter);
        this.testDbName = this.testDbName + "_r3";
        this.testQueryByPrepStmt = true;
        this.usePartOnMysql = false;
    }

    @Before
    public void setUp() {

    }

    @After
    public void tearDown() {
    }

    @Parameterized.Parameters(name = "{index}: partColTypeTestCase {0}")
    public static List<TestParameter> parameters() {
        // partition strategy: range/list/hash/range column/list column/key
        // data type: numeric/string/time
        return Arrays.asList(

            /**
             * ========= Range Columns ===========
             */
            /**
             * Range Columns
             */
            /* varchar */
            new TestParameter(
                "rc3_decimal_2400",
                new String[] {"c1"}/*col*/,
                new String[] {"decimal(24,0) default null "}/*data types*/,
                new String[] {"set sql_mode='';set names utf8;", "set names utf8;", "set names utf8;"},
                "range columns"/*strategy*/,
                new String[] {
                    "('-999999999999999999999999')",
                    "('-123456789012345678901234')",
                    "('-18446744073709551616')",
                    "('-18446744073709551615')",
                    "('-9223372036854775808')",
                    "('-4294967296')",
                    "('-2147483648')",
                    "('-16777216')",
                    "('-8388608')",
                    "('-65536')",
                    "('-32768')",
                    "('-255')",
                    "('-128')",
                    "('0')",
                    "('127')",
                    "('255')",
                    "('32767')",
                    "('65535')",
                    "('8388607')",
                    "('16777215')",
                    "('2147483647')",
                    "('4294967295')",
                    "('9223372036854775807')",
                    "('18446744073709551615')",
                    "('18446744073709551616')",
                    "('123456789012345678901234')",
                    "('999999999999999999999999')",
                    "(maxvalue)",
                }/*bndVal*/,
                new String[] {
                    "('-9999999999999999999999999')",
                    "('-1234567890123456789012345')",
                    "('-18446744073709551616')",
                    "('-18446744073709551615')",
                    "('-9223372036854775808')",
                    "('-4294967296')",
                    "('-2147483648')",
                    "('-16777216')",
                    "('-8388608')",
                    "('-65536')",
                    "('-32768')",
                    "('-255')",
                    "('-128')",
                    "('0')",
                    "('127')",
                    "('255')",
                    "('32767')",
                    "('65535')",
                    "('8388607')",
                    "('16777215')",
                    "('2147483647')",
                    "('4294967295')",
                    "('9223372036854775807')",
                    "('18446744073709551615')",
                    "('18446744073709551616')",
                    "('1234567890123456789012345')",
                    "('9999999999999999999999999')",
                }/*insertValues*/
                ,
                new String[] {
                    "('-12345678901234567890123450')",
                    "('-9999999999999999999999999')",
                    "('-1234567890123456789012345')",
                    "('-18446744073709551616')",
                    "('-18446744073709551615')",
                    "('-9223372036854775808')",
                    "('-4294967296')",
                    "('-2147483648')",
                    "('-16777216')",
                    "('-8388608')",
                    "('-65536')",
                    "('-32768')",
                    "('-255')",
                    "('-128')",
                    "('0')",
                    "('127')",
                    "('255')",
                    "('32767')",
                    "('65535')",
                    "('8388607')",
                    "('16777215')",
                    "('2147483647')",
                    "('4294967295')",
                    "('9223372036854775807')",
                    "('18446744073709551615')",
                    "('18446744073709551616')",
                    "('1234567890123456789012345')",
                    "('9999999999999999999999999')",
                    "('12345678901234567890123450')",
                }
                /*selectValues*/
                , new String[] {
                "('-12345678901234567890123450')",
                "('-9999999999999999999999999')",
                "('-1234567890123456789012345')",
                "('-18446744073709551616')",
                "('-18446744073709551615')",
                "('-9223372036854775808')",
                "('-4294967296')",
                "('-2147483648')",
                "('-16777216')",
                "('-8388608')",
                "('-65536')",
                "('-32768')",
                "('-255')",
                "('-128')",
                "('0')",
                "('127')",
                "('255')",
                "('32767')",
                "('65535')",
                "('8388607')",
                "('16777215')",
                "('2147483647')",
                "('4294967295')",
                "('9223372036854775807')",
                "('18446744073709551615')",
                "('18446744073709551616')",
                "('1234567890123456789012345')",
                "('9999999999999999999999999')",
                "('12345678901234567890123450')",
            }
                /*rngSortValues*/
            )

        );
    }

    @Test
    public void runTest() throws SQLException {
        super.testInsertAndSelect();
    }

}
